package gui;

import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

/**
 * Provides a simple Button for modal dialogs which closes it
 * @author diskostu
 * @version 1.0
 * 
 */
public class SimpleCloseButton extends JButton implements ActionListener {

	private Window parent;

	/**
	 * when using SimpleCloseButton, a parent container must be provided
	 * 
	 * @param parent
	 *           the parent container
	 * @since 1.0
	 */
	public SimpleCloseButton(Window parent) {
		this.addActionListener(this);
		this.parent = parent;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		this.parent.setVisible(false);
	}
}